// formPackage/components/idCardPushImg/idCardPushImg.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    // 默认上传身份证
    pushType: {
      type: String,
      value: "idCard"
    },
    topTitle: {
      type: String,
      value: "身份证信息"
    },
    idFrontImg: {
      type: String,
      value: ""
    },
    idBackImg: {
      type: String,
      value: ""
    },
    bussinessImg: {
      type: String,
      value: "",
    },
    mustFill:{
      type:Boolean,
      value:true
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    idFrontImgs: "",
    idBackImgs: "",
    bussinessImgs: "",
  },
  observers: {
    'idFrontImg': function (newValue) {
      this.setData({
        idFrontImgs: newValue
      })
    },
    'idBackImg': function (newValue) {
      this.setData({
        idBackImgs: newValue
      })
    },
    'bussinessImg': function (newValue) {
      this.setData({
        bussinessImgs: newValue
      })
    }
  },
  lifetimes: {
    attached: function () {
      // 在组件实例进入页面节点树时执行
      if (this.properties.idFrontImg) {
        this.setData({
          idFrontImgs: this.properties.idFrontImg
        })
      }
      if (this.properties.idBackImg) {
        this.setData({
          idBackImgs: this.properties.idBackImg
        })
      }
      if (this.properties.bussinessImg) {
        this.setData({
          bussinessImgs: this.properties.bussinessImg
        })
      }


    },
    detached: function () {

    },
  },


  /**
   * 组件的方法列表
   */
  methods: {
    pushImg(e) {
      let type = e.currentTarget.dataset.type;
      this.triggerEvent("pushImg", { type: type });
    },
  }
})
